package org.abio.XasML.reflect
{
	import org.abio.XasML.converter.object2Class;
	
	public class PropertyInfo extends MetadataAware
	{
		public function PropertyInfo()
		{
		}

		internal var _owner:ClassInfo=null;
		public function get owner():ClassInfo{	return this._owner;}
		internal var _bStatic:Boolean=false;
		public function get isStatic():Boolean{	return this._bStatic;}

		internal var name:String=null;
		public function get Name():String{	return this.name;}
		internal var access:String=null;
		public function get isReadable():Boolean{	return this.access==null || this.access=='readonly' || this.access=='readwrite';}
		public function get isWritable():Boolean{	return this.access==null || this.access=='writeonly' || this.access=='readwrite';}
		internal var type:String=null;
		public function get Type():Class{	return object2Class(this.type);}
		internal var declaredBy:String=null;
		internal var uri:String=null;

		public function setValue(instance:Object, value:Object):void{
			if(this.isWritable){
				if(this.isStatic){
					this.owner.defination[this.name]=value;
				}else{
					instance[this.name]=value;
				} 
			}else{
				throw('property.value is readonly');
			}
		}
		public function getValue(instance:Object):*{
			if(this.isReadable){
				if(this.isStatic){
					return this.owner.defination[this.name];
				}else{
					return instance[this.name];
				} 
			}else{
				throw('property.value is writeonly');
			}
		}
	}
}